package demoMod.stsconsole.commands;

import demoMod.stsconsole.dungeons.AbstractDungeon;
import demoMod.stsconsole.enums.ErrType;
import demoMod.stsconsole.helpers.LocalizedStrings;

import java.util.List;
import java.util.Scanner;

public class Chest extends AbstractCommand {
    @Override
    public void execute(String[] args, Scanner sc) {
        if (args.length != 0) {
            this.errMsg(ErrType.WRONG_ARGUMENT);
            return;
        }
        if (AbstractDungeon.currDungeon.currMapNode.room.chest == null) {
            this.errMsg(ErrType.COMMAND_NOT_AVAILABLE);
            return;
        }
        if (!AbstractDungeon.currDungeon.currMapNode.room.chest.isOpened()) {
            AbstractDungeon.currDungeon.currMapNode.room.chest.open();
            List<String> commandStrings = LocalizedStrings.getCommandStrings("Chest");
            AbstractDungeon.player.talk(commandStrings.get(0));
            System.out.println(commandStrings.get(1));
        } else {
            this.errMsg(ErrType.COMMAND_NOT_AVAILABLE);
        }
    }

    @Override
    public boolean requiredPrompt(String currentPrompt) {
        return currentPrompt.contains("Dungeon/");
    }
}
